package Task6;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        int n = StrToInt(str);
        System.out.println(n);
    }
    public static int StrToInt(String str) {
        int i  = 0;
        //判断字符串是否为空
        if(str == null){
            return 0;
        }
        if(str.length() == 0){
            return 0;
        }
        //字符串长度为1有三种情况 1.是+或者- 2.单个字母 3. 单个数字字符
        if(str.length() == 1){
            if(str.charAt(0) == '-' || str.charAt(0) == '+'){
                return 0;
            }
            if(str.charAt(0) - '0' > 9){
                return 0;
            }
            return valueof(str);
        }
        //判断字符串中是否夹带了除了数字字符和'+' '-'之外的字符
        while ( i < str.length() - 1){
            if(str.charAt(i) == '+' || str.charAt(i) == '-'){
                i++;
                //continue;
            }
            if(str.charAt(i) >= '0' && str.charAt(i) <= '9') {
                i++;
            }else {
                return 0;
            }
        }
        //首字符为+
        if(str.charAt(0) == '+' ){
            String newstring = str.substring(1,str.length());
            int n = valueof(newstring);
            return n;
        }
        //不带符号的数字字符串
        if(str.charAt(0) != '-' && str.charAt(0) != '+'){
            int n = valueof(str);
            return n;
        }
        //带'-'号的数字字符
        String newstring = str.substring(1,str.length());
        int m = valueof(newstring);
        return m* -1;

    }
    public static int valueof(String str){
        int length = str.length();
        if(length == 1){
            char ch = str.charAt(0);
            return (int)(ch - '0');
        }
        int n = 1;
        while ( length - 1 > 0){
            n = n*10;
            length --;
        }
        int number = 0;
        for (int i = 0; i < str.length(); i++) {
            char ch = str.charAt(i);
            number += (int)(ch - '0')*n;
            n /= 10;
        }
        return number;
    }
}
